﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Group3.Framework.Extensions
{
    public static class DictionaryExtension
    {
        public static V ReadPerKey<K, V>(this IDictionary<K, V> dict, K key)
        {
            if (dict != null && key != null)
                return dict.ContainsKey(key) ? dict[key] : default(V);
            else
                return default(V);
        }
        public static V ReadPerKey<V, K>(this IDictionary<string, V> dict, Func<K> GetKey) 
        {
            if (dict != null && GetKey != null)
                return dict.ReadPerKey(GetKey);
            else
                return default(V);
        }
        public static void Dispose<K, V>(this IDictionary<K, V> dict)
        {
            if (dict != null) dict.Clear();
            dict = null;
        }
    }
}
